#version 460
#extension GL_GOOGLE_include_directive : enable

#include "../../../../core/shader_tranform.h"
#include "../../../../core/shader_widget_panel.h"
 

layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWeights;
layout(location = 2) in vec2 inNormal;

layout(location = 0) out vec2 vUV;
layout(location = 1) out flat uint gInstanceIndex;
//layout(location = 2) out flat uint controlPointOffset;

 
void main(void) {
	//gl_Position = mat_ProjecView * mat_view * mat_Model[gl_InstanceIndex] * vec4(inPos, 0.0, 1.0);
	gInstanceIndex = gl_InstanceIndex;

	mat3x2 mat = m_LP_SD[gl_InstanceIndex];
	vec4 v = vec4(0.0, 0.0, 0.0, 1.0);

	mat2 rot;
	rot[0] = vec2(cos(mat[2].y), -sin(mat[2].y));
	rot[1] = vec2(sin(mat[2].y), cos(mat[2].y));

	v.xy = (inPos * mat[2].x) + ((mat[1]-mat[2].x) * inWeights.xy * rot);
	
	v.xy += mat[0];
	v.xy *= m_Scale;
	v.xy += m_Loc;
	
	//v.xy = round(v.xy) + 0.5;
	
	gl_Position = mat_ProjecView * v;
	//gl_PointSize = 4.0;
	vUV = inPos;
	//controlPointOffset = 0;
}



